package org.openkanban.client.ui.presenter;

import org.openkanban.client.ui.board.KanbanView;
import org.openkanban.shared.dto.KanbanDto;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;

/**
 * Callback that handles toggle kanban request
 */
public class ToggleKanbanRequestCallback implements RequestCallback {

    private KanbanView kanbanView;

    public ToggleKanbanRequestCallback(KanbanView kanbanView) {
	this.kanbanView = kanbanView;
    }

    @Override
    public void onResponseReceived(Request request, Response response) {
	KanbanDto kanbanDto = new KanbanDto(response.getText());
	if (kanbanDto.isCallSuccessfull()) {
	    kanbanView.togglePullableButton();
	    kanbanView.publish();
	}
    }

    @Override
    public void onError(Request request, Throwable exception) {

    }

}
